package com.taplinker.client.db.bean;

import android.content.ContentValues;

public class Conversation {
	public final static String CONVERSATION_ID = "conversationId";
	public final static String VISITOR_ID = "visitorId";
	public final static String SOURCE = "source";
	public final static String PRODUCT_ID = "productId";
	public final static String UNREAD_COUNT = "unreadCount";
	public final static String SOURCE_DESC = "sourceDesc";
	public final static String LOCATION = "location";
	public final static String REMARK = "remark";
	public final static String LAST_MESSAGE = "lastMessage";
	public final static String UPDATE_TIME = "updateTime";
	public final static String LAST_MESSAGE_TYPE = "lastMessageType";
	public final static String STATUS = "status";
	
	private String conversationId;
	private String visitorId;
	private String source;
	private String productId;
	private int unreadCount;
	private String sourceDesc;
	private String location;
	private String remark;
	private String lastMessage;
	private long updateTime;
	private String lastMessageType;
	private String status;
	
	public String getConversationId() {
		return conversationId;
	}
	public void setConversationId(String conversationId) {
		this.conversationId = conversationId;
	}
	public String getVisitorId() {
		return visitorId;
	}
	public void setVisitorId(String visitorId) {
		this.visitorId = visitorId;
	}
	public String getSource() {
		return source;
	}
	public void setSource(String source) {
		this.source = source;
	}
	public String getProductId() {
		return productId;
	}
	public void setProductId(String productId) {
		this.productId = productId;
	}
	public int getUnreadCount() {
		return unreadCount;
	}
	public void setUnreadCount(int unreadCount) {
		this.unreadCount = unreadCount;
	}
	public String getSourceDesc() {
		return sourceDesc;
	}
	public void setSourceDesc(String sourceDesc) {
		this.sourceDesc = sourceDesc;
	}
	public String getLocation() {
		return location;
	}
	public void setLocation(String location) {
		this.location = location;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getLastMessage() {
		return lastMessage;
	}
	public void setLastMessage(String lastMessage) {
		this.lastMessage = lastMessage;
	}
	public long getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(long updateTime) {
		this.updateTime = updateTime;
	}
	public String getLastMessageType() {
		return lastMessageType;
	}
	public void setLastMessageType(String lastMessageType) {
		this.lastMessageType = lastMessageType;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	
	public ContentValues convert2ContentValues() {
		ContentValues cv = new ContentValues();
		cv.put(CONVERSATION_ID, conversationId);
		cv.put(VISITOR_ID, visitorId);
		cv.put(SOURCE, source);
		cv.put(PRODUCT_ID, productId);
		cv.put(UNREAD_COUNT, unreadCount);
		cv.put(SOURCE_DESC, sourceDesc);
		cv.put(LOCATION, location);
		cv.put(REMARK, remark);
		cv.put(LAST_MESSAGE, lastMessage);
		cv.put(UPDATE_TIME, updateTime);
		cv.put(LAST_MESSAGE_TYPE, lastMessageType);
		cv.put(STATUS, status);
		return cv;
	}
	
	public static ContentValues convert2ContentValues(Conversation con) {
		ContentValues cv = null;
		if(con != null) {
			cv = new ContentValues();
			cv.put(CONVERSATION_ID, con.getConversationId());
			cv.put(VISITOR_ID, con.getVisitorId());
			cv.put(SOURCE, con.getSource());
			cv.put(PRODUCT_ID, con.getProductId());
			cv.put(UNREAD_COUNT, con.getUnreadCount());
			cv.put(SOURCE_DESC, con.getSourceDesc());
			cv.put(LOCATION, con.getLocation());
			cv.put(REMARK, con.getRemark());
			cv.put(LAST_MESSAGE, con.getLastMessage());
			cv.put(UPDATE_TIME, con.getUpdateTime());
			cv.put(LAST_MESSAGE_TYPE, con.getLastMessageType());
			cv.put(STATUS, con.getStatus());
		}
		return cv;
	}
	
	public static Conversation buildFromContentValues(ContentValues cv) {
		Conversation con = null;
		if(cv != null) {
			con = new Conversation();
			con.setConversationId(cv.getAsString(CONVERSATION_ID));
			con.setVisitorId(cv.getAsString(VISITOR_ID));
			con.setSource(cv.getAsString(SOURCE));
			con.setProductId(cv.getAsString(PRODUCT_ID));
			con.setUnreadCount(cv.getAsInteger(UNREAD_COUNT));
			con.setSourceDesc(cv.getAsString(SOURCE_DESC));
			con.setLocation(cv.getAsString(LOCATION));
			con.setRemark(cv.getAsString(REMARK));
			con.setLastMessage(cv.getAsString(LAST_MESSAGE));
			con.setUpdateTime(cv.getAsLong(UPDATE_TIME));
			con.setLastMessageType(cv.getAsString(LAST_MESSAGE_TYPE));
			con.setStatus(cv.getAsString(STATUS));
		}
		return con;
	}
}
